package sbeam.service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import sbeam.mapper.GameMapper;
import sbeam.mapper.TypeMapper;
import sbeam.model.Type;
import sbeam.service.TypeService;
@Service
public class TypeServiceImpl implements TypeService {

	@Autowired
	private TypeMapper dao;
	@Autowired
	private GameMapper gamedao;
	
	@Override
	public List<Type> findAllType() {
		return this.dao.findAllType();
	}

	@Override
	public List<Type> findType() {
		return this.dao.findType();
	}

	@Override
	public Type findTypeByName(String name) {
		return this.dao.findTypeByName(name);
	}

	@Override
	public Type findTypeById(String tid) {
		return this.dao.findTypeById(tid);
	}

	@Override
	public void addType(Type type) {
		this.dao.addType(type);
		
	}

	@Override
	public void updateType(Type type) {
		this.dao.updateType(type);
		
	}

	@Override
	public boolean isHavePalyGame(String tid) {
		if(this.gamedao.findPalyGameByType(Integer.valueOf(tid)).size()>0) {
			return true;
		}
		return false;
	}

	@Override
	public void deleteGameType(String tid) {
		this.dao.deleteType(tid);
		
	}

}
